<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>OA管理系统</title>
    <link rel="stylesheet" href="assets/css/style.css">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, width=device-width">
    <meta name="description" content="Bitter Mobile Template">
    <meta name="keywords" content="bootstrap, mobile template, cordova, phonegap, mobile, html, responsive" />

    <link href="./assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="./assets/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
    <script src="assets/js/lib/jquery-3.4.1.min.js"></script>
</head>

<body>

    <!-- Page loading -->
    <div class="loading">
        <div class="spinner-grow"></div>
    </div>
    <!-- * Page loading -->

    <!-- App Header -->
    <div class="appHeader">
        <div class="left">
            <a href="#" class="icon goBack">
                <i class="icon ion-ios-arrow-back"></i>
            </a>
        </div>
        <div class="pageTitle">请假</div>
    </div>
    <!-- * App Header -->

    <!-- App Capsule -->
    <div id="appCapsule">

        <div class="appContent">


            <form class="mb-2">
                <fieldset>
                    <br>
                    <br>
                    <br>
                    <div class="form-group">
                        <label for="dtp_input1" class="col-md-2 control-label">开始时间</label>
                        <div class="input-group date form_datetime col-md-5" data-date="1979-09-16T05:25:07Z"
                             data-date-format="yyyy-MM-dd hh:ii" data-link-field="dtp_input1">
                            <input class="form-control" size="16" type="text" value="" readonly id="start">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                            <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                        </div>
                        <input type="hidden" id="dtp_input1" value="" /><br />
                    </div>
                    <div class="form-group">
                        <label for="dtp_input1" class="col-md-2 control-label">结束时间</label>
                        <div class="input-group date form_datetime col-md-5" data-date="1979-09-16T05:25:07Z"
                             data-date-format="yyyy-MM-dd hh:ii" data-link-field="dtp_input1">
                            <input class="form-control" size="16" type="text" value="" readonly id="end">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                            <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                        </div>
                        <input type="hidden" id="dtp_input1" value="" /><br />
                    </div>

                    <div class="form-group">
                        <textarea class="form-control" rows="3" placeholder="请假原因" id="leaveReason"></textarea>
                    </div>
                    <div>
                        <button type="button" class="btn btn-primary btn-lg btn-block" id="subtn">
                            <i class="icon ion-ios-send"></i>
                            发送
                        </button>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
    <!-- appCapsule -->

    <script type="text/javascript" src="./assets/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="./assets/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
    <script type="text/javascript">

        Date.prototype.Format = function (fmt) { // author: meizz
            var o = {
                "M+": this.getMonth() + 1, // 月份
                "d+": this.getDate(), // 日
                "h+": this.getHours(), // 小时
                "m+": this.getMinutes(), // 分
                "s+": this.getSeconds(), // 秒
                "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
                "S": this.getMilliseconds() // 毫秒
            };
            if (/(y+)/.test(fmt))
                fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        }

        $("#subtn").click(function () {

            var leaveTime = new Date().Format("yyyy-MM-dd hh:mm");
            var end = $("#end").val();
            var start = $("#start").val();
            var leaveReason = $("#leaveReason").val();
            var data= {"leaveTime":leaveTime, "start": start, "end":end, "leaveReason":leaveReason};


            $.ajax({
                url: "/OASystem/leave/leave",
                dataType: "json",
                data: data,
                type: "post",
                success: function (data) {
                    if (data.code == 200){
                        alert("请求发送成功")
                       $('fieldset').html('<div class="alert alert-info alert-dismissible fade in">\n' +
                           '    <span class="close" data-dismiss="alert">&times;</span>' +
                           '    <p>提交成功，请等待审核！</p>\n' +
                           '</div>')
                        window.location.href = "./my.html"
                    }else {
                        alert("请求发送失败，请重试")
                        $("fieldset").html('<div class="alert alert-danger fade in">\n' +
                            '    <button type="button" class="close" data-dismiss="alert">&times;</button>\n' +
                            '    <strong>提示</strong> 提交失败！\n' +
                            '</div>\n')
                        location.reload();
                    }

                },
                error: function (err) {
                    alert("服务器出错");
                }
            });
        })





        $('.form_datetime').datetimepicker({
            language: 'zh_CN',
            weekStart: 1,
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            showMeridian: 1
        });
        $('.form_date').datetimepicker({
            language: 'fr',
            weekStart: 1,
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            minView: 2,
            forceParse: 0
        });
        $('.form_time').datetimepicker({
            language: 'fr',
            weekStart: 1,
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 1,
            minView: 0,
            maxView: 1,
            forceParse: 0
        });
    </script>



    <!-- ///////////// Js Files ////////////////////  -->

    <!-- Bootstrap-->
    <script src="assets/js/lib/popper.min.js"></script>
    <script src="assets/js/lib/bootstrap.min.js"></script>
    <!-- Owl Carousel -->
    <script src="assets/js/plugins/owl.carousel.min.js"></script>
    <!-- Main Js File -->
    <script src="assets/js/app.js"></script>


</body>

</html>